<?php

use yii\helpers\Html;
use yii\grid\GridView;
use yii\web\View;
/**
 * 综合查询
 */
/* @var $this yii\web\View */
/* @var $searchModel app\models\TmptableSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '综合查询';
$this->params['breadcrumbs'][] = $this->title;
$js=<<< Js
var exportLink = document.getElementById('export');
	exportLink.addEventListener('click', function(e){
		e.preventDefault();
		if(e.target.nodeName === "A"){
			tableExport('table-export', '导出文件', e.target.getAttribute('data-type'));
		}

	}, false);
Js;
$this->registerJs($js, View::POS_END, 'myAjax');
?>
<script src="<?= \Yii::getAlias('@web')?>/js/Blob.js"></script>

<script src="<?= \Yii::getAlias('@web')?>/js/FileSaver.js"></script>

<script src="<?= \Yii::getAlias('@web')?>/js/tableExport.js"></script>

<div class="tmptable-model-index">

   
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>
    <div>
        <div id="export" ><a class="btn btn-info"  data-type="xls" href="javascript:;">导出excel</a></div>	
    </div>
    
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
    	'tableOptions'=>[
    				'id'=>'table-export',
    				'class' => 'table table-striped table-bordered',
    		],
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],

            'stu_id',
            'stu_name',
            'sex'=>[
            		'value'=>function ($model){
            		return ($model->sex==0)?'男':'女';            		
        			},
        			'attribute'=>'sex',
        			'filter'=>['0'=>'男','1'=>'女'],
        					
        			],
            'card_id'=>[
                 'value'=> function($model){
                    $r="'".$model->card_id;                  
                    return $r;
                 } ,
                 'attribute'=>'card_id'
             ],
            'used_name',
            'nation',
            'political',
            'nativeplace',
            'religion',
            'height',
            'maritial_status',
            'blood_type',
            'telephone',
            'qq',
            'blank',
            'blank_num'=>[
                 'value'=> function($model){
                    $r="'".$model->blank_num;                  
                    return $r;
                 } ,
                 'attribute'=>'blank_num'
             ],
            'enroll_time',
            'stu_type'=>[
            		'value'=>function ($model){
            		if($model->stu_type==0)
            			$stu_type='本科生';
    				elseif ($model->stu_type==1)
    					$stu_type='硕士研究生';
    					else 
    						$stu_type='博士研究生';
            		return $stu_type;   	
   											 },
   					 'attribute'=>'stu_type',
   					 'filter'=>['0'=>'本科生','1'=>'硕士研究生','2'=>'博士研究生'],
   						 ],
            'major_name',
            'class_name',
            'status'=>[
            		'value'=>function ($model){
            		if($model->status==0)
            			$status='在读';
			    		elseif ($model->status==1)
			    		$status='休学';
    					elseif($model->status==2) 
    					$status='退学';
    						elseif($model->status==3)
    						$status='保留入学资格';
    						elseif($model->status==4)
    						$status='毕业';
    						elseif($model->status==5)
    						$status='肄业';
    						elseif($model->status==7)
    						$status='在读（在外校交流）';
    						elseif($model->status==8)
    						$status='在本校交流学习';
    						elseif($model->status==9)
    						$status='在本校交流学习结束';
    						else
    						$status='开除';
            		return $status;   	
    										},
   					 'attribute'=>'status',
 				     'filter'=>['0'=>'在读','1'=>'休学','2'=>'退学','3'=>'保留入学资格','4'=>'毕业','5'=>'肄业','6'=>'开除','7'=>'在读（在外校交流）',
    						'8'=>'在本校交流学习','9'=>'在本校交流学习结束'],
   						 ],
            'dorm_area'=>[
        				'value'=>function ($model){
        				if($model->dorm_area==0)
        					$dorm_area='东校园';
        				elseif ($model->dorm_area==1)
        				$dorm_area='西校园';
        				else 
        					$dorm_area='西校园南区';
        				return $dorm_area;
        				},
        				'attribute'=>'dorm_area',
        				'filter'=>['0'=>'东校园','1'=>'西校园','2'=>'西校园南区'],
        				 
        				],
            'dormitory',
            'dorm_num',
            'leader',
            'address',
            'recipient',
            'postal_code',
            'economic_status',
            'load',

        ],
    ]); ?>
</div>
